<?PHP
include 'adminStyles.php';
require_once "../../../../mainfile.php";
require_once('MOD_GLOBALS.php');
?>
<div style="margin: 8px;">

<table>
	<tr>
		<td style='font-size: 10px; color: #FF0000; vertical-align: bottom;'>*
		Indicates required fields</td>
		<td align="right">
		<?PHP if(!strpos ( $_SERVER['PHP_SELF'], 'admin')){
			echo "<div id='systemMessages' style='width: 400px; text-align: left;' dojoType='dijit.TitlePane'
				duration='200' title='System Messages:' open='false'></div>";
		} ?>
		</td>
	</tr>
</table>

<form id="add_new" name="add_new" action="" method="post"
	dojoType="dijit.form.Form">

<table style="border:1px #000000 solid;" cellspacing="0" cellpadding="0">
	<tr>
		<th colspan="3">Add New Event</th>
	</tr>
	<!-- START DATE ####################################################### -->
	<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">Event Date:<span
			style='font-size: 10px; color: #FF0000'>*</span></td>
		<td class="even" colspan="2"><input style="width:300px;" type="text" id="date1"
			name="date1" value="<?PHP echo date("c"); ?>"
			dojoType="dijit.form.DateTextBox" required="true" selector="date" />
		</td>
	</tr>
	<!-- START TIME ####################################################### -->
	<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">Event Time:<span
			style='font-size: 10px; color: #FF0000'>*</span></td>
		<td class="even" colspan="2"><input style="width:300px;" type="text" id="time1"
			name="time1" value="" dojoType="dijit.form.TimeTextBox"
			required="true" selector="time" /></td>
	</tr>

	<!-- END DATE ####################################################### -->
	<!--<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">End Date:</td>
		<td class="even" colspan="2"><input style="width:300px;" type="text" id="date2"
			name="date2" value="" dojoType="dijit.form.DateTextBox" required="false" selector="date" />
		</td>
	</tr>-->
	<!-- END TIME ####################################################### -->
	<!--<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">End Time:</td>
		<td class="even" colspan="2"><input style="width:300px;" type="text" id="time2"
			name="time2" value="" dojoType="dijit.form.TimeTextBox" required="false" selector="time" /></td>
	</tr>-->


	<!-- FREQUENCY ####################################################### -->
	<!-- <tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">Frequency:</td>
		<td class="even" colspan="2"><?PHP
		$result = $xoopsDB->query( "SELECT * FROM ".$xoopsDB->prefix("calendar_evnt_freq"). " order by ID asc" ) ;
		if ( $result ) {
		$checked = "";
		while($myrow = $xoopsDB->fetchArray($result)){

		if($checked == ""){
		echo '<input dojoType="dijit.form.RadioButton" checked="true" id="rec'.$myrow['ID'].'" name="frequency" value="'.$myrow['ID'].'" type="radio" />';
		$checked = "used";
		}else{
		echo '<input dojoType="dijit.form.RadioButton" id="rec'.$myrow['ID'].'" name="frequency" value="'.$myrow['ID'].'" type="radio" />';
		}
		echo '<label for="rec'.$myrow['ID'].'"> '.$myrow['DESCR'].' </label>';
		echo '&nbsp;  &nbsp; &nbsp;';
		}
		}
		?></td>
	</tr> -->
	<!-- CATEGORY ####################################################### -->
	<?PHP
	$result = $xoopsDB->query( "SELECT * FROM ".$xoopsDB->prefix("calendar_evnt_category")." WHERE ID <> 1 ORDER BY NAME asc" ) ;
	$rows = $xoopsDB->getAffectedRows($result);
	if ( $result && $rows > 0) { ?>
	<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">Category:</td>
		<td class="even" colspan="2"><select style="width:300px;"
			dojoType="dijit.form.FilteringSelect" name="eventCatAdd"
			id="eventCatAdd" autocomplete="false" value="1">
			<option value="1" selected="selected">Select Category:</option><!-- 1 is the Default category which should have an ID = 1 in calendar_events.ID -->
			<?PHP
			while ( $myrow = $xoopsDB->fetchArray($result) ) {
			echo "<option value=\"".$myrow['ID']."\">".$myrow['NAME']."</option>\n";
			}
			?>
		</select></td>
	</tr>
	<?PHP } ?>

	<!-- EVENT TITLE ####################################################### -->
	<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">Title:<span
			style='font-size: 10px; color: #FF0000'>*</span></td>
		<td class="even" colspan="2"><input style="width:300px;" type="text" name="title" id="title" value="" dojoType="dijit.form.ValidationTextBox" promptMessage="Enter the title of your event up to 80 characters" invalidMessage="A title is required up to 80 characters" regExp="[0-9a-zA-Z&''-'\s]{1,80}" required="true" trim="true" propercase="true" /></td>
	</tr>
	<!-- DESCRIPTION ####################################################### -->
	<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">Description:<br /></td>
		<td class="even" colspan="2" id="textAreaHolder">
		<div dojoType="dijit.form.Textarea" id="description"
			name="description" style="width: 300px; max-height:80px; overflow:hidden;"></div>
		</td>
	</tr>
	<!-- LOCATION ####################################################### -->
	<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">Location:<span
			style='font-size: 10px; color: #FF0000'>*</span></td>
		<td class="even" colspan="2"><input style="width:300px;" type="text" name="location" id="location"
			value="" dojoType="dijit.form.ValidationTextBox" regExp="[0-9a-zA-Z''-'\s]{1,80}"  promptMessage="Enter the location of this event" invalidMessage="Please enter a location for this event." required="true" trim="true" propercase="true" /></td>
	</tr>
	<!-- CONTACT NAME ####################################################### -->
	<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">Contact
		Name:<span style='font-size: 10px; color: #FF0000'>*</span></td>
		<td class="even" colspan="2"><input style="width:300px;" type="text" id="contact_name" name="contact_name"
			value="" dojoType="dijit.form.ValidationTextBox" regExp="[a-zA-Z''-'\s]{1,40}" promptMessage="Enter the contact person for this event" invalidMessage="A contact person is required for this event." required="true" trim="true" propercase="true" />
		</td>
	</tr>
	<!-- CONTACT PHONE ####################################################### -->
	<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">Contact
		Phone:<span	style='font-size: 10px; color: #FF0000'>*</span></td>
		<td class="even" colspan="2"><input style="width:300px;" type="text" id="contact_phone" name="contact_phone"
			value="" dojoType="dijit.form.ValidationTextBox" regExp="(1?(-?\d{3})-?)?(\d{3})(-?\d{4})" promptMessage="Enter phone number in format xxx-xxxx" invalidMessage="Invalid phone number." required="true" trim="true" />
		</td>
	</tr>
	<!-- CONTACT EMAIL ####################################################### -->
	<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">Contact
		Email:</td>
		<td class="even" colspan="2"><input style="width:300px;" type="text" id="contact_email" name="contact_email"
			value="" dojoType="dijit.form.ValidationTextBox" regExp="[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}" promptMessage="Enter email address." invalidMessage="Invalid Email Address." trim="true" propercase="false" />
		</td>
	</tr>
	<!-- EVENT WEBSITE ####################################################### -->
	<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">Event
		Website:</td>
		<td class="even" colspan="2"><input style="width:300px;" type="text" id="website" name="website"
			value="" dojoType="dijit.form.ValidationTextBox" regExp="(((ht|f)tp(s?))\://)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&amp;%\$#\=~_\-]+))*" promptMessage="Enter the URL for this event if there is one." invalidMessage="Please enter a valid URL including http://." trim="true"
			propercase="false" /></td>
	</tr>

	<!-- SUBMIT BUTTONS ####################################################### -->
	<tr>
		<td class="head" style="<?PHP echo $submitFormHdrs; ?>">
		</td>
		<td class="even">
			<button dojoType="dijit.form.Button" type="submit" onClick="preview();" style="height: 50px;padding-bottom:0;margin-bottom:0">Send</button>
			<button dojoType="dijit.form.Button" onClick="restForm('add_new','description');" style="height: 50px;padding-bottom:0;margin-bottom:0">Reset Form</button>
			<?PHP
			if(isset($_SESSION['XOOPS_ISADMIN']) && $_SESSION['XOOPS_ISADMIN'] != 1){
				echo "<div style='padding:0;margin-top:-10px; font-size: 10px; color: #FF0000; vertical-align: bottom;'>NOTE: Event Announcements must be approved by our staff. ";
				echo "Event submissions will also be sent to the following media outlets on approval: ";
				//INDICATE THEIR EVENT WILL BE SENT TO THE FOLLOWING MEDIA ENTITIES AS WELL:
				$result = $xoopsDB->query("select MediaName from ".$xoopsDB->prefix("calendar_mednot")." WHERE MediaName <> 'Default' ORDER BY MediaName ASC") ;
				if ( $result ) {
					while($myrow = $xoopsDB->fetchArray($result)){
						echo $myrow['MediaName'].";   ";
					}
				}

				echo "</div>";

			}//end if admin
			?>
		</td>
	</tr>

</table>
</form>
</div>
